package game;

import java.awt.Color;

public class DeathAnimation extends ParticleAnimation{
	private int index;
	private Color red = Color.RED;
	private ClipPlayer wav;
	public DeathAnimation(Level g, int x, int y) {
		super(g, x, y);
		index = 0;
		wav = new ClipPlayer("images/sfx.wav", level.canvas.settings.soundVolume);
		level.canvas.addMusic(wav);
	}
	public void update(){
		index += 10;
		if(index > 200){
			level.animations.remove(this);
			wav.finish();
			level.canvas.stopMusic(wav);
		}
	}
	
	public void draw(){
		level.canvas.bufGraphics.setColor(red);
		level.canvas.bufGraphics.fillRect(orgin.x+index-level.canvas.currentX, (int)(orgin.y+.01*Math.pow(index, 2))-index, 10, 10);
		level.canvas.bufGraphics.fillRect(orgin.x-index-level.canvas.currentX, (int)(orgin.y+.01*Math.pow(index, 2))-index, 10, 10);
		level.canvas.bufGraphics.fillRect(orgin.x+index-level.canvas.currentX, (int)(orgin.y+.01*Math.pow(index, 2))-2*index, 10, 10);
		level.canvas.bufGraphics.fillRect(orgin.x-index-level.canvas.currentX, (int)(orgin.y+.01*Math.pow(index, 2))-2*index, 10, 10);
	}

}
